package com.raymond.thread.manager.utils;

import com.raymond.thread.manager.SpringContextUtil;
import com.raymond.thread.manager.pool.DefaultThreadPool;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * 线程池工具类
 *
 * @author :  raymond
 * @version :  V1.0
 * @date :  2020-12-09 19:10
 */
public class ThreadPoolUtil {
    /**
     * 使用默认线程池执行任务
     * @param runnable 线程
     */
    public static void execute(Runnable runnable) {
        ThreadPoolTaskExecutor taskExecutor = SpringContextUtil.getBean(DefaultThreadPool.THREAD_POOL_NAME, ThreadPoolTaskExecutor.class);
        taskExecutor.execute(runnable);
    }
}
